package com.flying.list.exer;

import com.sun.source.doctree.SummaryTree;

import java.awt.*;
import java.util.ArrayList;
import java.util.Scanner;

public class Test {

    public static void main(String[] args) {

        ArrayList<Student> list = new ArrayList<>();

//        Student student = new Student("朵莉亚",18);
//        Student student1 = new Student("刘禅",20);
//        Student student2 = new Student("刘备",24);
//        Student student3 = new Student("孙尚香",24);

    Scanner scanner=new Scanner(System.in);

     while (true){
            System.out.println("""
                    1. 继续录入:
                    0. 结束录入:""");
            int i = scanner.nextInt();
            switch (i){
                case 1:
                    System.out.println("请输入学生姓名: ");
                    String name = scanner.next();
                    System.out.println("请输入年龄: ");
                    Integer age = scanner.nextInt();
                    list.add(new Student(name,age));
                    break;
                case 0:
                    System.out.println("结束录入!");
                    for (Student student : list) {
                        System.out.println(student);
                    }
                    System.exit(0);
            }
        }


    }





}
